﻿using System.Collections;
using System.Collections.Generic;
using UnityEngine;

namespace Tedu.ARPGDemo.Character
{
	/// <summary>
    /// 角色状态类：玩家状态、敌人状态的基类
    /// </summary>
	public class CharacterStatus : MonoBehaviour {
        public CharacterAnimationParameter animParams;

        public float attackDistance = 3;

        public float attackInterval = 3;

        public float baseATK = 100;

        public float defence = 100;

        public float HP = 100;

        public float maxHP = 100;

        public float maxSP = 100;

        public float SP = 100;

        protected Animator anim;
        private void Start()
        {
            anim = GetComponentInChildren<Animator>();
        }
        public void Damage(float val)
        {
            val -= defence;
            if (val > 0)
            {
                HP -= val;
                if (HP <= 0)
                {
                    Death();
                }
            }
        }

        public virtual void Death()
        {
            anim.SetBool(animParams.Death, true);
        }
        /// <summary>
        /// 判断是否正在攻击
        /// </summary>
        /// <returns></returns>
        public bool IsAttacking()
        {
            return anim.GetBool(animParams.Attack1) || anim.GetBool(animParams.Attack2) || anim.GetBool(animParams.Attack3);
        }
        //自加
        public bool IsRuning()
        {
            return anim.GetBool(animParams.Run);
        }
    }
}

